package com.thrd.taiexhibition.fragement.enterprise;

import android.os.Bundle;
import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.thrd.basicframework.bean.BaseFragment;
import com.thrd.basicframework.bean.BaseRecyclerAdapter;
import com.thrd.basicframework.ui.recyclerview.SpacesItemDecoration;
import com.thrd.basicframework.utils.DensityUtil;
import com.thrd.taiexhibition.R;
import com.thrd.taiexhibition.adapter.BusinessAdapter;
import com.thrd.taiexhibition.bean.BeanBusiness;

import java.util.List;

/**
 * 商业合作
 * @author: ${唐杰}
 * @date: 2021/3/31
 */
public class BusinessFragment extends BaseFragment {

    private RecyclerView mRecyclerView;
    private BusinessAdapter mAdapter;

    @Override
    protected int setLayoutResourceID() {
        return R.layout.fragment_business;
    }

    @Override
    protected void setUpView(View mContentView) {
        mRecyclerView = mContentView.findViewById(R.id.rv_recyclerview);
        LinearLayoutManager manager=  new LinearLayoutManager(getMContext());
        manager.setOrientation(RecyclerView.HORIZONTAL);
        mRecyclerView.addItemDecoration(new SpacesItemDecoration(0,0, DensityUtil.dip2px(getMContext(),16),0));
        mRecyclerView.setLayoutManager(manager);
    }

    @Override
    protected void setUpData() {
        Bundle mBundle =getArguments();
        List<BeanBusiness> mBeanBusinessList= (List<BeanBusiness>) mBundle.getSerializable("BeanBusinessList");
        if(mBeanBusinessList!=null){
            mAdapter = new BusinessAdapter(getMContext(),mBeanBusinessList);
            mRecyclerView.setAdapter(mAdapter);
        }

        mAdapter.setItemClick(new BaseRecyclerAdapter.ItemClick<BeanBusiness>() {
            @Override
            public void onItemClick(int p, BeanBusiness mBeanBusiness) {
                ARouter.getInstance().build("/app/enterpriseinfo").withSerializable("id",mBeanBusiness.getId()) .navigation();
            }
        });

    }
}
